import Cookies from 'js-cookie'

//key: 公用
const TokenKey = 'User-Token'
const NameKey = 'User-Name'
const AvatarKey = 'User-Avatar'

//保存用户信息
export function setUser(token,name,avatar) { 
    Cookies.set(NameKey, name)
    Cookies.set(AvatarKey, avatar)
    Cookies.set(TokenKey, token)
}

//获取用户信息
export function getUser(){
    return {
        token:Cookies.get(TokenKey),
        name:Cookies.get(NameKey),
        avatar:Cookies.get(AvatarKey)
    }
}

//登出
export function removeUser(){
    Cookies.remove(TokenKey)
    Cookies.remove(NameKey)
    Cookies.remove(AvatarKey)
}


